import {
  IsNotEmpty,
  IsString,
  Validate,
  ValidatorConstraint,
} from 'class-validator';
import { User } from 'src/user/entities/user.entity';
import { Entity, PrimaryGeneratedColumn, JoinColumn, OneToOne } from 'typeorm';
import { IsChineseIdCardConstraint } from 'src/utils/decorators/idCardDecorator';

@ValidatorConstraint()
@Entity()
export class CreateIdCardDto {
  @PrimaryGeneratedColumn()
  id: number;

  @IsString()
  @IsNotEmpty()
  // @Validate(IsChineseIdCardConstraint, [], {
  //   message: '请输入正确的身份证号码',
  // })
  value: string;

  @JoinColumn()
  @OneToOne(() => User)
  userId: number;
}
